//
//  DetailPay.m
//  FruitVIP
//
//  Created by 孙艳玲 on 15/7/3.
//  Copyright (c) 2015年 孙艳玲. All rights reserved.
//

#import "DetailPay.h"

#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)

@implementation DetailPay

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self getUI];
    }
    return self;
}


- (void)getUI
{
    
    UILabel *situationLable = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, SCREEN_WIDTH/2, SCREEN_HEIGHT/15)];
    situationLable.text = @"订单概况";
    situationLable.font = [UIFont systemFontOfSize:17];
    [self addSubview:situationLable];
    UILabel *orderNumbel = [[UILabel alloc] initWithFrame:CGRectMake(10, situationLable.frame.origin.y + situationLable.frame.size.height + 5, SCREEN_WIDTH/4, SCREEN_WIDTH/15)];
    orderNumbel.text = @"订单号:";
    orderNumbel.font = [UIFont systemFontOfSize:15];
    orderNumbel.textColor = [UIColor lightGrayColor];
    //    orderNumbel.backgroundColor = [UIColor yellowColor];
    [self addSubview:orderNumbel];
    
    UILabel *orderNumberLabel = [[UILabel alloc] initWithFrame:CGRectMake(orderNumbel.frame.origin.x + orderNumbel.frame.size.width + 5, orderNumbel.frame.origin.y, SCREEN_WIDTH -  orderNumbel.frame.size.width, orderNumbel.frame.size.height)];
    orderNumberLabel.text = @"87305749";
    orderNumberLabel.font = [UIFont systemFontOfSize:15];
    orderNumberLabel.textColor = [UIColor lightGrayColor];
    //    orderNumberLabel.backgroundColor = [UIColor redColor];
    [self addSubview:orderNumberLabel];
    
    
    UILabel *orderStatus = [[UILabel alloc] initWithFrame:CGRectMake(orderNumbel.frame.origin.x, orderNumbel.frame.origin.y+ orderNumbel.frame.size.height + 5, orderNumbel.frame.size.width, orderNumbel.frame.size.height)];
    orderStatus.text = @"状态:";
    orderStatus.font = [UIFont systemFontOfSize:15];
    orderStatus.textColor = [UIColor lightGrayColor];
    [self addSubview:orderStatus];
    
    
    UILabel *orderStatusLabel = [[UILabel alloc] initWithFrame:CGRectMake(orderNumberLabel.frame.origin.x, orderStatus.frame.origin.y, orderNumberLabel.frame.size.width, orderStatus.frame.size.height)];
    orderStatusLabel.text = @"支付成功";
    orderStatusLabel.textColor = [UIColor lightGrayColor];
    orderStatusLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:orderStatusLabel];

    
    UILabel *payWay = [[UILabel alloc] initWithFrame:CGRectMake(orderStatus.frame.origin.x , orderStatus.frame.origin.y + orderStatus.frame.size.height + 5,orderStatus.frame.size.width, orderStatus.frame.size.height)];
    payWay.text = @"提货网点:";
    payWay.font = [UIFont systemFontOfSize:15];
    payWay.textColor = [UIColor lightGrayColor];
    //    payWay.backgroundColor = [UIColor yellowColor];
    [self addSubview:payWay];
    
    UILabel *payWayLabel = [[UILabel alloc] initWithFrame:CGRectMake(payWay.frame.origin.x + payWay.frame.size.width + 5, payWay.frame.origin.y, orderStatusLabel.frame.size.width, payWay.frame.size.height)];
    payWayLabel.text = @"旭辉2号楼-光明便利";
    payWayLabel.font = [UIFont systemFontOfSize:15];
    payWayLabel.textColor = [UIColor lightGrayColor];
    //    payWayLabel.backgroundColor = [UIColor redColor];
    [self addSubview:payWayLabel];

    
    UILabel *payTime = [[UILabel alloc] initWithFrame:CGRectMake(payWay.frame.origin.x, payWay.frame.origin.y +payWay.frame.size.height + 5, payWay.frame.size.width, payWay.frame.size.height)];
    payTime.text = @"网店地址:";
    payTime.textColor = [UIColor lightGrayColor];
    payTime.font = [UIFont systemFontOfSize:15];
    [self addSubview:payTime];
    
    UILabel *payTimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(payWayLabel.frame.origin.x, payTime.frame.origin.y, payWayLabel.frame.size.width, payWayLabel.frame.size.height)];
    payTimeLabel.text = @"上海市长宁区通协路288弄2号楼";
    payTimeLabel.textColor = [UIColor lightGrayColor];
    payTimeLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:payTimeLabel];
    
    UILabel *payMoney = [[UILabel alloc] initWithFrame:CGRectMake(payTime.frame.origin.x, payTime.frame.origin.y + payTime.frame.size.height + 5, payTime.frame.size.width, payTime.frame.size.height)];
    payMoney.text = @"条形码:";
    payMoney.textColor = [UIColor lightGrayColor];
    payMoney.font = [UIFont systemFontOfSize:15];
    [self addSubview:payMoney];
    
    
    UIImageView *payImageView = [[UIImageView alloc] initWithFrame:CGRectMake(payMoney.frame.origin.x + payMoney.frame.size.width + 5, payMoney.frame.origin.y, payTimeLabel.frame.size.width/2, 2 * payTimeLabel.frame.size.height)];
    //        payImageView.backgroundColor = [UIColor redColor];
    payImageView.userInteractionEnabled = YES;
    UIImage *payImage = [UIImage imageNamed:@"code.png"];
    payImageView.image = payImage;
    payImageView.contentMode = UIViewContentModeScaleAspectFit;
    [self addSubview:payImageView];
//
    UILabel *name = [[UILabel alloc]initWithFrame:CGRectMake(payMoney.frame.origin.x , payImageView.frame.origin.y + payImageView.frame.size.height + 5, payMoney.frame.size.width, payMoney.frame.size.height)];
    name.text = @"提货码:";
    name.textColor = [UIColor lightGrayColor];
    name.font = [UIFont systemFontOfSize:15];
    [self addSubview:name];
    
    UILabel *price = [[UILabel alloc] initWithFrame:CGRectMake(name.frame.origin.x + name.frame.size.width + 5, name.frame.origin.y , payImageView.frame.size.width, name.frame.size.height)];
    price.text = @"202526";
    price.textColor = [UIColor lightGrayColor];
    price.font = [UIFont systemFontOfSize:15];
    //    price.backgroundColor = [UIColor redColor];
    [self addSubview:price];

    UILabel *priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(name.frame.origin.x , name.frame.origin.y + name.frame.size.height + 15, situationLable.frame.size.width, situationLable.frame.size.height)];
    priceLabel.text = @"商品清单";
    priceLabel.textColor = [UIColor blackColor];
    priceLabel.font = [UIFont systemFontOfSize:17];
    //    priceLabel.backgroundColor = [UIColor redColor];
    [self addSubview:priceLabel];
    
    
    UIView *listView = [[UIView alloc] initWithFrame:CGRectMake(priceLabel.frame.origin.x, priceLabel.frame.origin.y + priceLabel.frame.size.height + 5, SCREEN_WIDTH - 20, priceLabel.frame.size.height)];
    listView.backgroundColor = [UIColor colorWithRed:234.0/255.0 green:234.0/255.0 blue:234.0/255.0 alpha:1];
    [self addSubview:listView];
    
    UILabel *goodName = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, listView.frame.size.width/2, listView.frame.size.height)];
    goodName.text = @"商品名称";
    goodName.textAlignment = NSTextAlignmentCenter;
    goodName.font = [UIFont systemFontOfSize:15];
    [goodName.layer setBorderWidth:1.0];
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    CGColorRef colorref = CGColorCreate(colorSpace,(CGFloat[]){ 213/255.0, 213/255.0, 213/255.0, 1});
    [goodName.layer setBorderColor:colorref];
    [listView addSubview:goodName];
    
    
    

    UILabel *count = [[UILabel alloc] initWithFrame:CGRectMake(goodName.frame.origin.x + goodName.frame.size.width, goodName.frame.origin.y , goodName.frame.size.width/3, goodName.frame.size.height)];
    count.text = @"单价";
    count.textAlignment = NSTextAlignmentCenter;
    count.textColor = [UIColor blackColor];
    [count.layer setBorderWidth:1.0];
    [count.layer setBorderColor:colorref];
    count.font = [UIFont systemFontOfSize:15];
    [listView addSubview:count];

    UILabel *coutLabel = [[UILabel alloc] initWithFrame:CGRectMake(count.frame.origin.x + count.frame.size.width , count.frame.origin.y, count.frame.size.width, count.frame.size.height)];
    coutLabel.text = @"数量";
    coutLabel.textAlignment = NSTextAlignmentCenter;
    coutLabel.textColor = [UIColor blackColor];
    coutLabel.font = [UIFont systemFontOfSize:15];
    [coutLabel.layer setBorderWidth:1.0];
    [coutLabel.layer setBorderColor:colorref];
    [listView addSubview:coutLabel];

    
    UILabel *secondLine = [[UILabel alloc] initWithFrame:CGRectMake(coutLabel.frame.origin.x + coutLabel.frame.size.width, coutLabel.frame.origin.y , coutLabel.frame.size.width, coutLabel.frame.size.height)];
    secondLine.text = @"小计";
    secondLine.textAlignment = NSTextAlignmentCenter;
    secondLine.font = [UIFont systemFontOfSize:15];
    [secondLine.layer setBorderWidth:1.0];
    [secondLine.layer setBorderColor:colorref];
    [listView addSubview:secondLine];
    
    
    UIView *firstGoodsView = [[UIView alloc] initWithFrame:CGRectMake(listView.frame.origin.x, listView.frame.origin.y + listView.frame.size.height, listView.frame.size.width, listView.frame.size.height)];
    firstGoodsView.backgroundColor = [UIColor whiteColor];
    [self addSubview:firstGoodsView];
    
    
    UILabel *firstName = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, firstGoodsView.frame.size.width/2, firstGoodsView.frame.size.height)];
    firstName.text = @"台湾红心芭乐";
    firstName.textAlignment = NSTextAlignmentCenter;
    firstName.font = [UIFont systemFontOfSize:15];
    [firstName.layer setBorderWidth:1.0];
    [firstName.layer setBorderColor:colorref];
    [firstGoodsView addSubview:firstName];
    
    
    UILabel *firstPrice = [[UILabel alloc] initWithFrame:CGRectMake(firstName.frame.origin.x + firstName.frame.size.width, 0, firstName.frame.size.width/3, firstName.frame.size.height)];
    firstPrice.textAlignment = NSTextAlignmentCenter;
    firstPrice.text = @"7.5";
    NSString *str = @"￥";
    firstPrice.text = [str stringByAppendingString:firstPrice.text];
    firstPrice.font = [UIFont systemFontOfSize:15];
    [firstPrice.layer setBorderWidth:1.0];
    [firstPrice.layer setBorderColor:colorref];
    [firstGoodsView addSubview:firstPrice];
    
    
    UILabel *firstCount = [[UILabel alloc] initWithFrame:CGRectMake(firstPrice.frame.origin.x + firstPrice.frame.size.width, 0, firstPrice.frame.size.width, firstPrice.frame.size.height)];
    firstCount.text = @"1";
    firstCount.textAlignment = NSTextAlignmentCenter;
    firstCount.font = [UIFont systemFontOfSize:15];
    [firstCount.layer setBorderWidth:1.0];
    [firstCount.layer setBorderColor:colorref];
    [firstGoodsView addSubview:firstCount];
    
    UILabel *firstAll = [[UILabel alloc] initWithFrame:CGRectMake(firstCount.frame.origin.x + firstCount.frame.size.width, 0, firstCount.frame.size.width, firstCount.frame.size.height)];
    firstAll.text = @"7.50";
    firstAll.textAlignment = NSTextAlignmentCenter;
    [firstAll.layer setBorderWidth:1.0];
    [firstAll.layer setBorderColor:colorref];
    [firstGoodsView addSubview:firstAll];
    
    
    UIView *secondGoodsView = [[UIView alloc] initWithFrame:CGRectMake(firstGoodsView.frame.origin.x, firstGoodsView.frame.origin.y + firstGoodsView.frame.size.height, listView.frame.size.width, listView.frame.size.height)];
    secondGoodsView.backgroundColor = [UIColor whiteColor];
    [self addSubview:secondGoodsView];
    
    
    UILabel *secondName = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, secondGoodsView.frame.size.width/2, secondGoodsView.frame.size.height)];
    secondName.text = @"新西兰特级嘎啦果";
    secondName.textAlignment = NSTextAlignmentCenter;
    secondName.font = [UIFont systemFontOfSize:15];
    [secondName.layer setBorderWidth:1.0];
    [secondName.layer setBorderColor:colorref];
    [secondGoodsView addSubview:secondName];
    
    
    UILabel *secondPrice = [[UILabel alloc] initWithFrame:CGRectMake(secondName.frame.origin.x + secondName.frame.size.width, 0, secondName.frame.size.width/3, secondName.frame.size.height)];
    secondPrice.textAlignment = NSTextAlignmentCenter;
    secondPrice.text = @"7.5";
    secondPrice.text = [str stringByAppendingString:secondPrice.text];
    secondPrice.font = [UIFont systemFontOfSize:15];
    [secondPrice.layer setBorderWidth:1.0];
    [secondPrice.layer setBorderColor:colorref];
    [secondGoodsView addSubview:secondPrice];
    
    
    UILabel *secondCount = [[UILabel alloc] initWithFrame:CGRectMake(secondPrice.frame.origin.x + secondPrice.frame.size.width, 0, secondPrice.frame.size.width, secondPrice.frame.size.height)];
    secondCount.text = @"3";
    secondCount.textAlignment = NSTextAlignmentCenter;
    secondCount.font = [UIFont systemFontOfSize:15];
    [secondCount.layer setBorderWidth:1.0];
    [secondCount.layer setBorderColor:colorref];
    [secondGoodsView addSubview:secondCount];
    
    UILabel *secondAll = [[UILabel alloc] initWithFrame:CGRectMake(secondCount.frame.origin.x + secondCount.frame.size.width, 0, secondCount.frame.size.width, secondCount.frame.size.height)];
    secondAll.text = @"1.00";
    secondAll.textAlignment = NSTextAlignmentCenter;
    [secondAll.layer setBorderWidth:1.0];
    [secondAll.layer setBorderColor:colorref];
    [secondGoodsView addSubview:secondAll];
    
    
    UIView *lastView = [[UIView alloc] initWithFrame:CGRectMake(secondGoodsView.frame.origin.x, secondGoodsView.frame.origin.y + secondGoodsView.frame.size.height, secondGoodsView.frame.size.width, 3 * secondGoodsView.frame.size.height)];
    lastView.backgroundColor = [UIColor whiteColor];
    [lastView.layer setBorderWidth:1.0];
    [lastView.layer setBorderColor:colorref];
    [self addSubview:lastView];
    
    
    UILabel *allCount = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, lastView.frame.size.width  -10, lastView.frame.size.height/3)];
//    allCount.backgroundColor = [UIColor redColor];
    NSString *allStr = @"共";
    NSString *strCount = @"2";
    NSString *strGood = @"件商品";
    allCount.text = [NSString stringWithFormat:@"%@%@%@   ", allStr,strCount, strGood];
    allCount.textAlignment = NSTextAlignmentRight;
    [lastView addSubview:allCount];
    
    
    UILabel *lastGoodMoney = [[UILabel alloc] initWithFrame:CGRectMake(lastView.frame.size.width/2, allCount.frame.origin.y + allCount.frame.size.height, lastView.frame.size.width/4 - 10, allCount.frame.size.height)];
    lastGoodMoney.text = @"商品金额:";
    lastGoodMoney.textColor = [UIColor lightGrayColor];
    lastGoodMoney.font = [UIFont systemFontOfSize:15];
    [lastView addSubview:lastGoodMoney];
    
    UILabel *detailMoney = [[UILabel alloc] initWithFrame:CGRectMake(lastGoodMoney.frame.origin.x + lastGoodMoney.frame.size.width + 10, lastGoodMoney.frame.origin.y, lastGoodMoney.frame.size.width, lastGoodMoney.frame.size.height)];
    detailMoney.text = @"10.50";
    detailMoney.text = [str stringByAppendingString:detailMoney.text];
    detailMoney.textColor = [UIColor colorWithRed:183/255.0 green:50/255.0 blue:71.0/255.0 alpha:1];
    detailMoney.font = [UIFont systemFontOfSize:17];
    detailMoney.textAlignment = NSTextAlignmentRight;
    [lastView addSubview:detailMoney];
    
    
    UILabel *actMoney = [[UILabel alloc] initWithFrame:CGRectMake(lastGoodMoney.frame.origin.x, lastGoodMoney.frame.origin.y + lastGoodMoney.frame.size.height, lastGoodMoney.frame.size.width, lastGoodMoney.frame.size.height)];
    actMoney.text = @"实付金额:";
    actMoney.textColor = [UIColor lightGrayColor];
    actMoney.font = [UIFont systemFontOfSize:15];
    [lastView addSubview:actMoney];
    
    
    UILabel *detailAct = [[UILabel alloc] initWithFrame:CGRectMake(actMoney.frame.origin.x + actMoney.frame.size.width + 10, actMoney.frame.origin.y, detailMoney.frame.size.width, detailMoney.frame.size.height)];
    detailAct.text = @"5.50";
    detailAct.text = [str stringByAppendingString:detailAct.text];
    detailAct.textColor = [UIColor colorWithRed:183/255.0 green:50/255.0 blue:71.0/255.0 alpha:1];
    detailAct.font = [UIFont systemFontOfSize:17];
    detailAct.textAlignment = NSTextAlignmentRight;
//    detailAct.backgroundColor = [UIColor yellowColor];
    [lastView addSubview:detailAct];
    
    
    self.contentSize = CGSizeMake(SCREEN_WIDTH, orderNumbel.frame.size.height + orderStatus.frame.size.height + payWay.frame.size.height + payTime.frame.size.height + payMoney.frame.size.height + payImageView.frame.size.height + listView.frame.size.height + firstGoodsView.frame.size.height + secondGoodsView.frame.size.height + lastView.frame.size.height + 200);

}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
